# Maintainer: kpcyrd <git@rxv.cc>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>

pkgname=cargo-audit
pkgver=0.17.5
pkgrel=1
pkgdesc="Audit Cargo.lock for crates with security vulnerabilities"
url="https://github.com/RustSec/cargo-audit"
depends=('cargo')
arch=('loong64' 'x86_64')
license=('MIT' 'APACHE')
options=(!lto)
source=("https://github.com/RustSec/rustsec/archive/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('a5db055fa654c43a8e4326165e3afe4b8dd04e9e28b5e183a04c4a874952892c')
b2sums=('bc2e289597deefc43ab32a8197d2694242d5b9bb140f018d27d82cd089a3dcbe45dd721b7f245e9cbe18b1a5682cf9cecc79625d9152ed501b18f8e27f89e6cc')

prepare() {
  cd rustsec-${pkgname}-${pkgver}/${pkgname}
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd rustsec-${pkgname}-${pkgver}
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --release --locked
}

check() {
  cd rustsec-${pkgname}-${pkgver}/${pkgname}
  export RUSTUP_TOOLCHAIN=stable
  cargo test --release --locked
}

package() {
  cd rustsec-${pkgname}-${pkgver}/${pkgname}
  install -Dm755 "../target/release/${pkgname}" -t "${pkgdir}"/usr/bin
  install -Dm644 LICENSE-MIT -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
